package com.beifu.manager.service.organization.impl;

import com.beifu.manager.dao.OrganizerMapper;
import com.beifu.manager.model.Organizer;
import com.beifu.manager.model.OrganizerExample;
import com.beifu.manager.service.organization.OrganizerService;
import com.mds.manager.utils.PageUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 再壮 on 2018/6/18.
 */
@Service
public class OrganizerServiceImpl implements OrganizerService {

    @Autowired
    private OrganizerMapper organizerMapper;


    @Override
    public List<Organizer> selectByExample(OrganizerExample example) {
        return organizerMapper.selectByExample(example);
    }

    @Override
    public int countByExample(OrganizerExample example) {
        return organizerMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(OrganizerExample example) {
        return organizerMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(int id) {
        return organizerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(Organizer record) {
        return organizerMapper.insertSelective(record);
    }

    @Override
    public Organizer selectByPrimaryKey(int id) {
        return organizerMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByExampleSelective(@Param("record") Organizer record, @Param("example") OrganizerExample example) {
        return organizerMapper.updateByExampleSelective(record, example);
    }

    @Override
    public int updateByExample(@Param("record") Organizer record, @Param("example") OrganizerExample example) {
        return organizerMapper.updateByExample(record, example);
    }

    @Override
    public int updateByPrimaryKeySelective(Organizer record) {
        return organizerMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Organizer record) {
        return organizerMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageUtils getRolePage(PageUtils Page) {
        OrganizerExample example = (OrganizerExample) Page.getQueryParames();
        List<Organizer> list = organizerMapper.getRolePage((Page.getPage()-1)*Page.getLimit(),Page.getLimit(), example);
        int count = organizerMapper.countByExample(null);
        Page.setList(list);
        Page.setCountNum(count);
        return Page;
    }

    @Override
    public int batchDel(String[] idsArr) {
        return organizerMapper.batchDel(idsArr);
    }

    @Override
    public PageUtils getOrganizerPages(PageUtils page) {
        OrganizerExample example = (OrganizerExample) page.getQueryParames();
        List<Organizer> list = organizerMapper.getRolePage((page.getPage()-1)*page.getLimit(),page.getLimit(), example);
        int count = organizerMapper.countByExample(example);
        page.setList(list);
        page.setCountNum(count);
        return page;
    }
}
